//
//  CityViewController.m
//  FastDoctor
//
//  Created by 李通 on 16/7/6.
//  Copyright © 2016年 sc. All rights reserved.
//

#import "CityViewController.h"
#import "CityDTO.h"
#import "NextCityViewController.h"

@interface CityViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) NSArray *cityList;

@property (nonatomic,strong) NSArray *cities;

@end

@implementation CityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    SCREEN_HEIGHT
    // Uncomment the following line to preserve selection between presentations.
    
    self.tableView.tableFooterView = [[UIView alloc]init];
}


#pragma mark - tableView delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.cityList.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    CityDTO *cityModel = self.cityList[indexPath.row];
    
    cell.textLabel.text = cityModel.name;
    
    return cell;
}

#pragma mark - 点击tableViewCell跳转的设置
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    CityDTO *cityModel = self.cityList[indexPath.row];
    
    NextCityViewController *nextViewController = [[NextCityViewController alloc]init];
    
    nextViewController.cities = cityModel.cities;
    
    nextViewController.title = @"选择当前城市位置";
    
    [self.navigationController pushViewController:nextViewController animated:YES];
}

#pragma mark - 数据懒加载
- (NSArray *)cityList {
    
    if (!_cityList) {
        
        _cityList = [CityDTO cityList];
    }
    return _cityList;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
